<html>
<head>
    <title></title>
    <meta charset="utf-8">
    <script type="text/javascript" src="lib/require.js"></script>
</head>
<body style="margin:0px">
    <canvas id="main"></canvas>
    <script type="text/javascript">
        require(['../dist/claygl', 'js/createCompositor'], function(clay, createCompositor) {
            var renderer = new clay.Renderer({
                canvas : document.getElementById('main'),
                devicePixelRatio : 1.0
            });
            renderer.resize(window.innerWidth, window.innerHeight);

            var camera = new clay.camera.Perspective({
                aspect : renderer.getViewportAspect()
            });
            camera.position.set(0, 0, 20);

            var scene = new clay.Scene();
            var control = new clay.plugin.OrbitControl({
                domElement : renderer.canvas,
                target : camera
            });

            var cubeMap = new clay.TextureCube({
                width : 512,
                height : 512,
                type : clay.Texture.FLOAT
            });

            clay.util.texture.loadPanorama(
                renderer,
                'assets/textures/hdr/pisa.hdr',
                cubeMap,
                {
                    exposure: 2
                }
            );

            var skybox = new clay.plugin.Skybox({
                scene : scene
            });
            skybox.material.set('environmentMap', cubeMap);
            skybox.material.define('fragment', 'RGBM_ENCODE');

            var timeline =  new clay.Timeline();
            timeline.start();

            var compositor = createCompositor({
                scene: scene,
                camera: camera
            });

            timeline.on('frame', function() {
                // renderer.render(scene, camera);
                compositor.render(renderer);
                control.update();
            });
        });

    </script>
</body>
</html>